package cz.proks.easyhelpdesk.gae.core.util;

import java.util.LinkedList;
import java.util.List;

import cz.proks.easyhelpdesk.api.model.Helpdesk;

public abstract class DomainGenerator {
	protected final Random random;
	
	public DomainGenerator() {
		this.random = new Random();
	}
	
	public static DomainGenerator getHelpdeskGenerator() {
		return new HelpdeskGenerator();
	}
	
	public abstract <T> T generate();
	
	public abstract <T> List<T> generateCollection(int count);
	
	public static class HelpdeskGenerator extends DomainGenerator  {

		@Override
		public Helpdesk generate() {
			Helpdesk helpdesk = new Helpdesk();
			
			helpdesk.setId(random.randomLong());
			helpdesk.setName(random.randomString());
			helpdesk.setCreated(random.randomDate());
			
			return helpdesk;
		}

		@Override
		public List<Helpdesk> generateCollection(int count) {
			List<Helpdesk> list = new LinkedList<Helpdesk>();
			
			for (int i = 0; i < count; i++)
				list.add(generate());
			
			return list;
		}			
	}	
}
